package com.mazaiting.manager;

import com.mazaiting.mybatisplus.encrypt.encryptor.BasicTextEncryptor;
import com.mazaiting.mybatisplus.encrypt.encryptor.CachedTextEncryptor;
import com.mazaiting.scheduler.domain.entity.SysQuartzJob;
import com.mazaiting.scheduler.mapper.ISysQuartzJobMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import javax.annotation.Resource;

/**
 * mybatisPlus部分业务测试
 * @title: MyBatisSensitiveUtils
 * @Author danghailiang
 * @Date: 2022/4/13 10:04
 * @Version 1.0
 */
@SpringBootTest
@ExtendWith(SpringExtension.class)
public class MyBatisSensitiveUtils {

    /**
     * 定时服务
     */
    @Resource
    private ISysQuartzJobMapper sysQuartzJobMapper;

    /**
     * 手机号邮箱获取输出脱敏查看
     */
    @Test
    public void SensitiveTest(){
        SysQuartzJob sysQuartzJob = sysQuartzJobMapper.selectById(1);
        System.out.println("mobile:"+sysQuartzJob.getPhone());
        System.out.println("email:"+sysQuartzJob.getEmail());
        //  sysQuartzJob.setPhone("18199891674");
        //  sysQuartzJob.setEmail("1072067273@qq.com");
        //  System.out.println("mobile:"+sysQuartzJob.getPhone());
        //  System.out.println("email:"+sysQuartzJob.getEmail());
        //  sysQuartzJobMapper.updateById(sysQuartzJob);
        //  System.out.println("mobile:"+sysQuartzJob.getPhone());
        //  System.out.println("email:"+sysQuartzJob.getEmail());
        /*SysQuartzJob sysQuartzJob = sysQuartzJobMapper.selectById(1);
        sysQuartzJob.setId(2L);
        sysQuartzJob.setPhone("13788889999");
        sysQuartzJob.setEmail("danghailiang@qq.com");
        sysQuartzJobMapper.insert(sysQuartzJob);*/

    }

    /**
     * base64测试
     */
    @Test
    public void encryptTest() throws Exception {
        CachedTextEncryptor base64Encryptor = new BasicTextEncryptor();
        String decryptMobile = base64Encryptor.decrypt("jKP6IlhjG4wXg1y0D+w658R+ec4NjmbK", "5ZOG5ZWmQeaipjEyMzQ1Ng==");
        String decryptEmail = base64Encryptor.decrypt("9BUEXP9WIOwSi/EPtIX/Vi91AQ4bb8eFWB8i4iJzr0I=", "5ZOG5ZWmQeaipjEyMzQ1Ng==");
        System.out.println("decryptMobile:"+decryptMobile);
        System.out.println("decryptEmail:"+decryptEmail);
    }
}
